//
//  ViewController.m
//  02.18P.M. ControlFun
//
//  Created by student on 16/2/18.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)backTap:(id)sender {
//    1.[self.view endEditing:YES];
    [self.nameTextField resignFirstResponder];
    [self.passwordTextField resignFirstResponder];
}

- (IBAction)slideValueChanged:(UISlider *)sender {
    int value = sender.value;
    self.slideValueLabel.text=[NSString stringWithFormat:@"%i",value];
}

- (IBAction)segementChanged:(UISegmentedControl *)sender {
    if (sender.selectedSegmentIndex==0) {
        self.doSthBtn.hidden=YES;
        self.leftSwitch.hidden=NO;
        self.rightSwitch.hidden=NO;
    }
    else{
        self.leftSwitch.hidden=YES;
        self.rightSwitch.hidden=YES;
        self.doSthBtn.hidden=NO;
    }
    
}

- (IBAction)switchChanged:(UISwitch *)sender {
    BOOL open = sender.on;
    [self.leftSwitch setOn:open animated:YES];
    [self.rightSwitch setOn:open animated:NO];
    
}

- (IBAction)doSthPress:(UIButton *)sender {
    
    UIActionSheet *sheet=[[UIActionSheet alloc]initWithTitle:@"你确定么？" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"是的,我确定!" otherButtonTitles: nil];
    [sheet showInView:self.view];

}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSString *str=[NSString stringWithFormat:@"%@,放轻松,一切都正常运行了",self.nameTextField.text];
    if (buttonIndex==actionSheet.destructiveButtonIndex) {
        UIAlertView *view =[[UIAlertView alloc]initWithTitle:@"某些事项被执行了" message:str delegate:self cancelButtonTitle:@"哦,耶!" otherButtonTitles:nil];
        [view show];
        
    }
}
@end
